﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Annual_faculty_promotions.Core.Domain;

namespace Annual_faculty_promotions.Data.Mapping
{
    public class UserStageMap : EntityTypeConfiguration<UserStage>
    {
        public UserStageMap()
        {
            this.HasKey(c => c.Id);

            this.HasRequired(c => c.User)
                .WithMany(c => c.UserRoleUnivercityStructures)
                .HasForeignKey(c => c.UserId)
                .WillCascadeOnDelete();

            //this.HasRequired(c => c.Role)
            //   .WithMany(c => c.UserRoleUnivercityStructures)
            //   .HasForeignKey(c => c.RoleId)
            //   .WillCascadeOnDelete();

            this.HasRequired(c => c.UnivercityStructure)
           .WithMany(c => c.UserStages)
           .HasForeignKey(c => c.UnivercityStructureId)
           .WillCascadeOnDelete();

            this.HasRequired(c => c.Stage)
           .WithMany(c => c.UserStages)
           .HasForeignKey(c => c.StageId)
           .WillCascadeOnDelete(false);
        }
    }
}
